// PlayerStatus.java

package com.mytech.cslive;

public enum PlayerStatus {
	ALIVE,
	DEAD,
	HAS_FLAG,
	IN_SPAWN_POINT,
	FLAG_RETURNED;
	
	private int secondsLeft;
	public static final String ALIVE_STRING   	     = "Alive";
	public static final String DEAD_STRING 		     = "Dead";
	public static final String HAS_FLAG_STRING       = "Has Flag";
	public static final String FLAG_RETURNED_STRING  = "Flag Returned";
	public static final String IN_SPAWN_POINT_STRING = "In Spawn Point";
	public static final int    INVALID_INDEX         = -1;
	
	public static final String[] STATUS_VALUES = 
		{ ALIVE_STRING, DEAD_STRING, 
			HAS_FLAG_STRING, FLAG_RETURNED_STRING, 
				IN_SPAWN_POINT_STRING};
	
	public static int getInvalidIndex() {
		return INVALID_INDEX;
	}
	
	public int getSecondsLeft() {
		return secondsLeft;
	}

	public void setSecondsLeft(int secondsLeft) {
		this.secondsLeft = secondsLeft;
	}
	
	public static String getAliveString() {
		return ALIVE_STRING;
	}
;
	public static String getDeadString() {
		return DEAD_STRING;
	}

	public static String getHasFlagString() {
		return HAS_FLAG_STRING;
	}

	public static String getFlagReturnedString() {
		return FLAG_RETURNED_STRING;
	}

	public static String getInSpawnPointString() {
		return IN_SPAWN_POINT_STRING;
	}

	public static String[] getStatusValues() {
		return STATUS_VALUES;
	}

	public static PlayerStatus parseString(String statusString) {
		PlayerStatus status = null;
		
		if (statusString.equals(getAliveString())) {
			status = PlayerStatus.ALIVE;
		} else if (statusString.equals(getDeadString())) {
			status = PlayerStatus.DEAD;
		} else if (statusString.equals(getHasFlagString())) {
			status = PlayerStatus.HAS_FLAG;
		} else if (statusString.equals(getFlagReturnedString())) {
			status = PlayerStatus.FLAG_RETURNED;
		} else if (statusString.equals(getInSpawnPointString())) {
			status = PlayerStatus.IN_SPAWN_POINT;
		}
		
		return (status);
	}
	
	@Override
	public String toString() {
		return (super.toString());
	}
	
	public String toPresentableString() {
		String statusString = null;
		
		if (this.equals(PlayerStatus.ALIVE)) {
			statusString = getAliveString();
		} else if (this.equals(PlayerStatus.DEAD)) {
			statusString = getDeadString();
		} else if (this.equals(PlayerStatus.HAS_FLAG)) {
			statusString = getHasFlagString();
		} else if (this.equals(PlayerStatus.FLAG_RETURNED)) {
			statusString = getFlagReturnedString();
		} else if (this.equals(PlayerStatus.IN_SPAWN_POINT)) {
			statusString = getInSpawnPointString();
		}
		
		return (statusString);
	}
}
